const Router = require('koa-router');
const router = new Router();
const tool = require('../../tools/tool')
const {db, QueryTypes} = require("../../models/db");
// 在已派单中增加
router.post('/receipt/addSavePdList', async ctx => {
    let user = ctx.user
    let tenantId = user.tenantId;
    let body = ctx.request.body;
    let list = body.list;
    let doId = body.doId;
    let doName = body.doName;
    let ret = []
    list.map(row => {
        ret.push({
            tenantId,
            buId: row.buId,
            billId: row.billId,
            billNo: row.billNo,
            billDate: row.billDate,
            buName: row.buName,
            transType: row.transType,
            transTypeName: row.transTypeName,
            leftAmount: row.leftAmount,
            arrearsReal: row.arrearsReal,
            nowCheck: 0,
            yhAmount: 0,
            salesId: row.salesId,
            salesName: row.salesName,
            doId: doId,
            doName: doName,
            state: '收款中',
            cby: user.id,
            cbyName: user.name,
            createdAt: tool.getTime(),
        })
    })
    await db.models['receiptPd'].bulkCreate(ret)
    return ctx.suc('增加成功' )
})


module.exports = router;
